package com.duobaoyu.dby.supply.common.biz.bo.refund;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.DiffBuilder;
import org.apache.commons.lang3.builder.DiffResult;
import org.apache.commons.lang3.builder.Diffable;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Objects;

/**
 * @author yw
 * @description
 * @date 2023/9/28 14:15
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AfterSaleItemOutBO implements Serializable, Diffable<AfterSaleItemOutBO> {

    private Long id;
    /**
     * 描述：渠道商品编码
     */
    private String channelProductCode;
    /**
     * 描述：渠道编码
     */
    private String channelCode;
    /**
     * 描述：渠道运费退款金额
     */
    private BigDecimal channelFreightActualRefundAmount;
    /**
     * 描述：商品类型
     */
    private String productType;
    /**
     * 描述：是否删除 0-否 1-是
     */
    private Integer delFlag;
    /**
     * 描述：三级分类id
     */
    private Long thirdClassifyId;
    /**
     * 描述：订单编号
     */
    private String orderSn;
    /**
     * 描述：售后状态
     */
    private Integer afterSaleStatus;
    /**
     * 描述：sku图片
     */
    private String skuPic;
    /**
     * 描述：渠道实付金额
     */
    private BigDecimal channelActualPaidAmount;
    /**
     * 描述：版本号-用作乐观锁
     */
    private Integer version;
    private String showServerName;
    /**
     * 描述：商户实付金额
     */
    private BigDecimal merchantActualPaidAmount;

    /**
     * 平台商品单价
     */
    private BigDecimal itemPlatformUnitPrice;
    /**
     * 描述：渠道申请退款金额
     */
    private BigDecimal applyRefundAmount;

    /**
     * 描述：商品货物状态
     */
    private Integer goodsStatus;
    /**
     * 描述：售后原因
     */
    private String reasonCode;
    /**
     * 描述：售后单号
     */
    private String afterSaleSn;
    /**
     * 描述：商品编码
     */
    private String productCode;
    /**
     * 描述：订单数量
     */
    private Double purchaseNum;
    /**
     * 描述：渠道sku编码
     */
    private String channelSkuCode;
    /**
     * 描述：退款金额
     */
    private BigDecimal channelActualRefundAmount;
    /**
     * 描述：售后来源
     */
    private Integer afterSaleSource;
    /**
     * 描述：售后类型
     */
    private Integer afterSaleType;
    /**
     * 描述：售后原因描述
     */
    private String reasonName;
    /**
     * 描述：运费申请退款金额
     */
    private BigDecimal freightApplyRefundAmount;

    /**
     * 描述：申请数量
     */
    private Integer applyNum;
    /**
     * 描述：售后描述
     */
    private String afterSaleRemark;

    /**
     * 售后图片
     */
    private List<String> afterSaleImageList;
    /**
     * 描述：业务售后单号
     */
    private String bizAfterSaleSn;
    /**
     * 描述：sku编码
     */
    private String skuCode;
    /**
     * 描述：sku名称
     */
    private String skuName;

    /**
     * 业务来源
     */
    private String serverName;
    /**
     * 描述：三级分类名称
     */
    private String thirdClassifyName;

    /**
     * 描述：渠道售后单号
     */
    private String channelAfterSaleSn;

	@Override
	public DiffResult<AfterSaleItemOutBO> diff(AfterSaleItemOutBO obj) {
		DiffBuilder<AfterSaleItemOutBO> diffBuilder =
				new DiffBuilder<>(this, obj, ToStringStyle.SHORT_PREFIX_STYLE);
		diffBuilder.append("商品货物状态", this.goodsStatus, obj.getGoodsStatus());
		diffBuilder.append("售后原因", this.reasonCode, obj.getReasonCode());
		diffBuilder.append("售后原因描述", this.reasonName, obj.getReasonName());
		if (Objects.nonNull(obj.getApplyRefundAmount())) {
			diffBuilder.append("渠道申请退款金额", this.applyRefundAmount, obj.getApplyRefundAmount().setScale(2, RoundingMode.HALF_UP));
		}
		if (Objects.nonNull(obj.getFreightApplyRefundAmount())) {
			diffBuilder.append("运费申请退款金额", this.freightApplyRefundAmount, obj.getFreightApplyRefundAmount().setScale(2, RoundingMode.HALF_UP));
		}
		if (Objects.nonNull(obj.getChannelActualRefundAmount())) {
			diffBuilder.append("渠道实际退款金额", this.channelActualRefundAmount, obj.getChannelActualRefundAmount().setScale(2, RoundingMode.HALF_UP));
		}
		if (Objects.nonNull(obj.getChannelFreightActualRefundAmount())) {
			diffBuilder.append("渠道实际退款运费", this.freightApplyRefundAmount, obj.getChannelFreightActualRefundAmount().setScale(2, RoundingMode.HALF_UP));
		}
		return diffBuilder.build();
	}
}
